function deepClone(obj) {
  if (!obj || typeof obj !== "object") return;

  let newObj = Array.isArray(obj) ? [] : {};

  for (let key in obj) {
    if (obj.hasOwnProperty(key)) {
      newObj[key] =
        typeof obj[key] === "object" ? deepClone(obj[key]) : obj[key];
    }
  }

  return newObj;
}

const o1 = {
  user: {
    name: "kaho",
    like: {
      free: "ball",
    },
  },
};

const o2 = deepClone(o1);
o1.user.like.free = "water";
console.log(o2);
